Skip to main content

All Questions

Tagged with
0votes
3answers
50views

Making each word in a text file an item in a bash array

I have a string of text and spaces which looks like this: macOS windows arch-linux ubuntu_linux I want to append each item (with whitespace denoting a break between items) to a bash array. How do I ...
EmberNeurosis's user avatar
2votes
1answer
198views

How can I take a sub-array in bash of the first N elements of a string array with elements containing spaces?

This question is similar to this one but it differs from it: Consider this array with string elements which may contain spaces: a@W:$ arr=("eins" "zwei" "eins plus zwei" &...
Adalbert Hanßen's user avatar
-1votes
2answers
60views

Split string with 0-2 / (or determine there's none) (Bash)

Update: Up to 2 "/" in the string. String structure is either: Character set name/LF Character set name/CRLF Character set name/CRLF/(unknown purpose, likely a number) Character set name ...
strider's user avatar
0votes
2answers
101views

How to check value inside a file using bash?

I'm trying to check if the value inside a file is "0". COUNT_EXECUTION=$(< /tmp/count) if [ "$COUNT_EXECUTION" == "0" ]; then echo "Try restart service." ...
Aderbal Nunes's user avatar
0votes
3answers
219views

Convert json data to comma separated string

I have a json object that has an unknown number of variables, like this: { "var1": 123, "var2": 456, "var3": 789 } How can I automatically convert it to form ...
teeeeee's user avatar
0votes
1answer
71views

Problem matching new terminal window ID with xdotool in Bash

I have a script that kicks off a new terminal window that I want to move to a specific position on the left terminal using xdotool. After kicking off the terminal I run xdotool search --class gnome-...
Tex's user avatar
-1votes
1answer
45views

I can't grep some inputrc string

bind -p |grep -E "\\e.\":" work but bind -p |grep -E "\\e\\C-.\":" don't work I tried a lot of combination
user3634569's user avatar
1vote
1answer
72views

GNU parallel: how to call exported bash function with empty string argument?

Scenario: $ process(){ echo "[$1] [$2] [$3]" ; } ; export -f process $ process "x" "" "a.txt" [x] [] [a.txt] Here we see that the 2nd argument is empty string ...
pmor's user avatar
  • 593
-1votes
5answers
169views

add empty line before every line that contains certain characters

I have a lot of markdown files that contains something like this: * header A - item 1 - item 2 ** sub-header A1 ** sub-header A2 * header B - item 1 - item 2 ** sub-header B1 ** sub-...
GhostOrder's user avatar
0votes
0answers
63views

Why isn't passed quoted $@ a single argument? [duplicate]

Why isn't passed quoted $@ a single argument? f2() { echo "f2: $1" } f1() { local x=("$@") f2 "${x[@]}" } f1 x y Invocation: $ bash t537.sh f2: ...
pmor's user avatar
  • 593
-1votes
1answer
107views

Checking if I'm correct about the order of operations in Bash

Guten Tag! I'm a rookie in everything Bash-related. I'm familiarizing with the syntax and wanted to know if the order of operations in this command is as I thought or not. The command: echo 2 * 3 > ...
elkronequis's user avatar
-1votes
2answers
4kviews

How does the `tr` command work?

I was playing around with tr and got some unexpected results. What is happening in these situations? I don't understand what is happening under the hood, or perhaps I'm not using this command ...
BadHorsie's user avatar
0votes
0answers
141views

Bash reverse search inserting characters into command after hitting tab

SYSTEM: Ubuntu: 20.04 Kernel: 5.4.0-162-generic bash: 5.0.17(1) I found a strange problem that when I use bash's reverse search with CTRL+r, I will find a command I want to run. I select TAB to ...
Dave's user avatar
  • 700
0votes
1answer
537views

bash: string variable contains asterisk. how to use this variable for searching etc with grep, sed?

Have a nice day I have got text file (zz.txt): Chemical name 3-Aminopropane-1-sulphonic acid Synonym(s) -- Homotaurine * Tramiprosate -- Chemical name Common name and synonyms ... I have variable s=&...
Alex Den's user avatar
0votes
2answers
569views

Use SED to replace part of a current variable with user input variable

I'm trying to replace only part of the existing variable with a new user input variable as below: #Current Variable: gdbName=Test.MY.DOMAIN.COM <--I need to replace the "Test" (This can ...
Ali's user avatar
  • 123

153050per page
close